<!doctype html>
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
    <meta name="format-detection" content="telephone=no"/>
    <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
    <title>订单详情</title>
    <link href="<?php echo TEMPLATE_SITE_URL;?>/css/common.css" type="text/css" rel="stylesheet">
    <link href="<?php echo TEMPLATE_SITE_URL;?>/css/sale.css" type="text/css" rel="stylesheet">
    <link href="<?php echo TEMPLATE_SITE_URL;?>/css/sale-detail.css" type="text/css" rel="stylesheet">
    <script type="text/javascript" src="<?php echo RESOURCE_SITE_URL;?>/js/zepto.js" charset="utf-8"></script>
</head>
<body>
    <div id="contentbox">
    <div class="progressMain">
    				<?php if($output['order']['order_state']>2){?>
	    				<?php if(!empty($output['order']['order_comment'])){?>
	                    <div class="progressItem">
	                        <div class="content">
	                        	<a href="<?php echo BASE_SITE_URL;?>/index.php?act=payment&op=comment&order_id=<?php echo $output['order']['id'];?>">
		                        	<div class="more"><img src="<?php echo TEMPLATE_SITE_URL;?>/images/moreIcon.png" width="19" height="20"></div>
		                        </a>
	                            <div class="title finish">
	                                <div>已评价</div>
	                            </div>
	                            <div class="detail">
	                                <div class="time">评价时间：<?php echo date("Y年m月d日 H:i",$output['order']['comment_time']);?></div>
	                            </div>
	                        </div>
	                    </div>
	                    <?php }else{?>
	                    <div class="progressItem">
	                        <div class="content">
	                            <div class="title finish">
	                                <div>等待买家评价</div>
	                            </div>
	                            <div class="detail">
	                                <div class="time">截至时间：<?php echo date("Y年m月d日 H:i",($output['order']['shouhuo_time']+7*24*3600));?></div>
	                            </div>
	                        </div>
	                    </div>
	                    <?php }?>
    				<?php }?>
    
        			<?php if($output['order']['order_state']>2){?>
                    <div class="progressItem">
                        <div class="content">
                            <div class="title finish">
                                <div>已收货,交易完成</div>
                            </div>
                            <div class="detail">
                                <div class="time">收货时间：<?php echo date("Y年m月d日 H:i",$output['order']['shouhuo_time']);?></div>
                            </div>
                        </div>
                    </div>
					<?php }?>
    				<?php if($output['order']['order_state']>1){?>
    				
    				<?php if($output['order']['is_tuihuo']==1){?>
	    				<?php if($output['order']['is_accept']==1){?>
		    				<?php if($output['order']['is_fail']!='1'){?>
		    				<div class="progressItem">
		                        <div class="content">
		                            <div class="title paid">
		                                <div>同意退货</div>
		                            </div>
		                            <div class="detail">
		                                <div class="time">同意时间：<?php echo date("Y年m月d日 H:i",$output['order']['tuihuo_time']);?></div>
		                            </div>
		                        </div>
		                    </div>
		                    <?php }else{?>
		                    <div class="progressItem">
		                        <div class="content">
		                            <div class="title paid">
		                                <div>交易失败</div>
		                            </div>
		                            <div class="detail">
		                            	<div class="time">原因：买家退款</div>
		                                <div class="time">结束时间：<?php echo date("Y年m月d日 H:i",$output['order']['finish_time']);?></div>
		                            </div>
		                        </div>
		                    </div>
		                    <?php }?>
	                    <?php }?>	                    
    				<?php }?>
    				<?php if($output['order']['currentexchange']==1&&$output['order']['is_fail']==1){?>
    					<div class="progressItem">
	                        <div class="content">
	                            <div class="title paid">
	                                <div>交易失败</div>
	                            </div>
	                            <div class="detail">
	                                <div class="time">失败原因：买家未收货</div>
	                            </div>
	                        </div>
	                    </div>
    				<?php }?>
    				
                    <div class="progressItem">
                        <div class="content">
                        	<a href="http://m.kuaidi100.com/index_all.html?type=<?php echo $output['order']['expresscode']?>&postid=<?php echo $output['order']['express']?>">
		                        <div class="more"><img src="<?php echo TEMPLATE_SITE_URL;?>/images/moreIcon.png" width="19" height="20"></div>
		                    </a>
                            <div class="title delivery">
                            	<?php if($output['order']['order_state']==3){?>                           	
                                <div>已发货</div>
                                <?php }else{?>
	                                <?php if($output['order']['currentexchange']==1){?>
	                                <div>已发货</div>
	                                <?php }else{?>
	                                	<?php if($output['order']['is_fail']!='1'){?>
	                                	<div>已发货,等待买家确认</div>
	                                	<?php }else{?>
	                                	<div>已发货</div>
	                                	<?php }?>
	                                <?php }?>
                                
                                <?php }?>
                            </div>
                            <div class="detail">
                                <div class="time">发货时间：<?php echo date("Y年m月d日 H:i",$output['order']['fahuo_time']);?></div>
                            </div>
                        </div>
                    </div>
					<?php }?>
    				<?php if($output['order']['order_state']>0){?>
	    				<?php if($output['order']['is_fail']==1 && $output['order']['is_tuihuo']!=1&&$output['order']['currentexchange']!='1'){?>
	    				<div class="progressItem">
	                        <div class="content">
	                            <div class="title paid">
	                                <div>交易失败</div>
	                            </div>
	                            <div class="detail">
	                                <div class="time">失败原因：卖家未发货</div>
	                            </div>
	                        </div>
	                    </div>
	    				<?php }else{?>
	    				<?php if($output['order']['currentexchange']!='1'){?>
	    				<div class="progressItem">
	                        <div class="content">
	                            <div class="title paid">
	                                <div>已付款</div>
	                            </div>
	                            <div class="detail">
	                                <div class="time">付款时间：<?php echo date("Y年m月d日 H:i",$output['order']['payment_time']);?></div>
	                            </div>
	                        </div>
	                    </div>
	                    <?php }?>
	    				<?php }?>                    
					<?php }?>
					
					<?php if($output['order']['order_state']>0){?>
					<div class="progressItem">
                        <div class="content">
                            <div class="title deal">
                                <div>竞拍成功</div>
                            </div>
                            <div class="detail">
                                <div class="time">成功时间：<?php echo date("Y年m月d日 H:i",$output['auction']['end_time']);?></div>
                            </div>
                        </div>
                    </div>
					<?php }else{?>
						<?php if($output['order']['is_fail']==1){?>
						<div class="progressItem">
	                        <div class="content">
	                            <div class="title deal">
	                                <div>交易失败</div>
	                            </div>
	                            <div class="detail">
	                                <div class="time">截至时间：<?php echo date("Y年m月d日 H:i",($output['auction']['end_time']+3600*48));?></div>
	                            </div>
	                        </div>
	                    </div>
						<?php }else{?>
						<div class="progressItem">
						<a href="index.php?act=payment&op=orderpayment&order_id=<?php echo $output['order']['id'];?>">
	                        <div class="content">
	                            <div class="title deal">
	                                <div>竞拍成功，等待买家付款</div>
	                            </div>
	                            <div class="detail">
	                                <div class="time">截至时间：<?php echo date("Y年m月d日 H:i",($output['auction']['end_time']+3600*48));?></div>
	                            </div>
	                        </div>
	                    </a>
	                    </div>
						<?php }?>
					<?php }?>

                    <div class="progressItem">
                        <div class="content">
                            <div class="title sale">
                                <div>开始竞拍</div>
                            </div>
                            <div class="detail">
                                <div class="time">开始时间：<?php echo date("Y年m月d日 H:i",$output['auction_log']['add_time']);?></div>
                            </div>
                        </div>
                    </div>
    </div>

    <div class="orderMain">
    	<div class="orderItem">
            <div class="title" style="background-image: url(<?php echo $output['userinfo']['avatar'];?>)">
                <div class="nickname">
                    <a href="index.php?act=my&op=home&uid=<?php echo $output['userinfo']['user_id'];?>&user_id=<?php echo $output['userinfo']['user_id']?>"><?php echo $output['userinfo']['nickname'];?></a>
                </div>    
                <a href="tel:<?php echo $output['userinfo']['mobile'];?>" class="tel"></a>   
                <div class="status">                
                <?php 
                	if($output['order']['order_state']=='0'){ 
						if($output['order']['is_fail'] == '1'){
							echo '交易失败';
						}else{
							echo '待付款';
						}					
					}elseif($output['order']['order_state']=='1'){
						echo '已支付未发货';
					}elseif($output['order']['order_state']=='2'){
						if($output['order']['is_tuihuo']==1){
							if($output['order']['is_fail']==1){
								echo '交易失败';
							}else{
								if($output['order']['is_accept']==1){
									echo '同意退货';
								}elseif($output['order']['is_accept']==2){
									echo '待收货';
								}else{
									echo '申请退货';
								}							
							}
							
						}else{
							if($output['order']['currentexchange']=='1'&&$output['order']['is_fail']==1){
								echo '交易失败';							
							}else{
								echo '待收货';
							}
							
						}
						
					}else{ 
						echo '交易完成';
					}?>                    
                </div>
            </div>

            <div class="info">
            	<a href="index.php?act=index&auction_id=<?php echo $output['auction']['id'];?>">
            		<?php if($output['order']['order_state']=='0'){?>
            		<?php if($output['order']['is_fail']==1){?>
            		<div class="content">
                        <div class="goodsImg" style="background-image:url(<?php echo UPLOAD_SITE_URL.'/shop/auction/'.$output['auction']['auction_add_date'].'/'.$output['auction']['auction_img1'];?>);">
                        <?php if($output['auction']['freeship']==1){?>
                        <div class="post">包邮</div>
                        <?php }?>
                        </div>
                        <div class="desc"><?php echo bearshop_auction_description_substr($output['auction']['auction_description']); ?></div>
                        <ul>
                        	<li><span>交易失败,买家未付款</span></li>            
            				<li><span>截止时间：</span><?php echo date("Y-m-d H:i:s",$output['order']['add_time']);?></li>
						</ul>
                    </div> 
            		<?php }else{?>
            		<div class="content">
                        <div class="goodsImg" style="background-image:url(<?php echo UPLOAD_SITE_URL.'/shop/auction/'.$output['auction']['auction_add_date'].'/'.$output['auction']['auction_img1'];?>);">
                        <?php if($output['auction']['freeship']==1){?>
                        <div class="post">包邮</div>
                        <?php }?>
                        </div>
                        <div class="desc"><?php echo bearshop_auction_description_substr($output['auction']['auction_description']); ?></div>
                        <ul>
                        	<li><span>成交金额：</span>￥<?php echo $output['order']['price'];?>元</li>            
            				<li><span>成交时间：</span><?php echo date("Y-m-d H:i:s",$output['order']['add_time']);?></li>
						</ul>
                    </div> 
            		<?php }?>
  
                    <?php }elseif($output['order']['order_state']=='1'){?>
                    <div class="content">
			          <div class="goodsImg" style="background-image:url(<?php echo UPLOAD_SITE_URL.'/shop/auction/'.$output['auction']['auction_add_date'].'/'.$output['auction']['auction_img1'];?>);">
			            <?php if($output['auction']['freeship']==1){?>
                        <div class="post">包邮</div>
                        <?php }?>
			          </div>
			          <div class="desc"><?php echo bearshop_auction_description_substr($output['auction']['auction_description']); ?></div>
			          <ul>
			            <li><span>成交金额：</span>￥<?php echo $output['order']['price'];?>元</li>            
			            <li><span>发货期限：</span><?php echo date("Y-m-d H:i:s",($output['order']['payment_time']+3*24*3600));?></li>
			          </ul>
			        </div>
                    <?php }elseif($output['order']['order_state']=='2'){?>
	                    <?php if($output['order']['is_fail']!='1'){?>
	                    <div class="content">
				          <div class="goodsImg" style="background-image:url(<?php echo UPLOAD_SITE_URL.'/shop/auction/'.$output['auction']['auction_add_date'].'/'.$output['auction']['auction_img1'];?>);">
				          	<?php if($output['auction']['freeship']==1){?>
	                        <div class="post">包邮</div>
	                        <?php }?>
				          </div>
				          <div class="desc"><?php echo bearshop_auction_description_substr($output['auction']['auction_description']); ?></div>
				          <ul>
	                        	<li><span>成交金额：</span>￥<?php echo $output['order']['price'];?>元</li>            
	            				<li><span>成交时间：</span><?php echo date("Y-m-d H:i:s",$output['order']['add_time']);?></li>
				          </ul>
				        </div>
				        <?php }else{?>
				        <div class="content">
				          <div class="goodsImg" style="background-image:url(<?php echo UPLOAD_SITE_URL.'/shop/auction/'.$output['auction']['auction_add_date'].'/'.$output['auction']['auction_img1'];?>);">
				          	<?php if($output['auction']['freeship']==1){?>
	                        <div class="post">包邮</div>
	                        <?php }?>
				          </div>
				          <div class="desc"><?php echo bearshop_auction_description_substr($output['auction']['auction_description']); ?></div>
				          <ul>
	                        	<li><span>失败原因：</span>买家退货</li>            
	            				<li><span>失败时间：</span><?php echo date("Y-m-d H:i:s",$output['order']['finish_time']);?></li>
				          </ul>
				        </div>
				        <?php }?>
                    <?php }elseif($output['order']['order_state']=='3'){?>
                    <div class="content">
			          <div class="goodsImg" style="background-image:url(<?php echo UPLOAD_SITE_URL.'/shop/auction/'.$output['auction']['auction_add_date'].'/'.$output['auction']['auction_img1'];?>);">
			          	<?php if($output['auction']['freeship']==1){?>
                        <div class="post">包邮</div>
                        <?php }?>
			          </div>
			          <div class="desc"><?php echo bearshop_auction_description_substr($output['auction']['auction_description']); ?></div>
			          <ul>
                        	<li><span>成交金额：</span>￥<?php echo $output['order']['price'];?>元</li>            
            				<li><span>成交时间：</span><?php echo date("Y-m-d H:i:s",$output['order']['add_time']);?></li>
			          </ul>
			        </div>
                    <?php }?>   
                </a>
                </div>
                  <?php if($output['order']['order_state']=='1' && $output['order']['is_fail']!='1'){?>      	
			      <div class="tools">
			      	      <button class="mysendout" order_id="<?php echo $output['order']['id'];?>">立即发货</button>
			      </div>
			      <?php }elseif($output['order']['order_state']=='2'){?>
			      	  <?php if($output['order']['is_accept']==2&&$output['order']['is_fail']!=1){?>
			      	  <div class="tools">
				      	      <button class="accept" order_id="<?php echo $output['order']['id'];?>">同意</button>
				      </div>
			      	  <?php }?>
				      <?php if(empty($output['order']['is_accept']) && $output['order']['is_tuihuo']==1){?>
				      <div class="tools">				      		  
				      		  <button class="refuse" order_id="<?php echo $output['order']['id'];?>">拒绝</button>
				      	      <button class="accept" order_id="<?php echo $output['order']['id'];?>">同意</button>
				      </div>
				      <?php }?>
				      
				      <?php if(($output['order']['is_accept']==1)&&(!empty($output['order']['tuihuo_express']))&&($output['order']['is_fail']!='1')){?>
				      <div class="tools">
				      	      <button class="confirmtuikuan" order_id="<?php echo $output['order']['id'];?>">确认退款</button>
				      </div>
				      <?php }?>
			      <?php }elseif($output['order']['order_state']=='0' && $output['order']['is_fail']!='1'){?>
			      <div class="tools">
			      	      <button class="currentexchange" order_id="<?php echo $output['order']['id'];?>">当面交易</button>
			      </div>
			      <?php }?>

           </div>
        </div>

	    <div class="orderInfoMain">
	        <div class="title">订单信息</div>
		    <div class="saleUri">
	        	<span class="label">买家电话：</span>
	        	<span class="value"><a class="buynumber" href="tel:<?php echo $output['userinfo']['mobile'];?>"></a><?php echo $output['userinfo']['mobile'];?></span>
	        </div>        
	        <div class="saleUri">
	        	<span class="label">拍品编号：</span>
	        	<span class="value"><?php echo $output['auction']['auction_sn']?></span>
	        </div>
	        <div class="saleUri">
	        	<span class="label">货款交易单号：</span>
	        	<span class="value"><?php echo $output['order']['order_sn']?></span>
	        </div>
	    </div>
	
	    
	    <?php if($output['order']['order_state']>=1){?>
	    	<?php if($output['order']['currentexchange']!='1'){?>
		    <div class="orderInfoMain">
		        <div class="title">收发货信息</div>
		        <div class="saleUri">
		        	<span class="label">收货人：</span>
		        	<span class="value"><?php echo $output['address']['name'];?></span>
		        	<span class="valueleft"><?php echo $output['address']['tele'];?></span>
		        </div>
		        <div class="saleUri">
		        	<span class="value">
		        		<?php echo $output['address']['prov_name'];?>
			            <?php echo $output['address']['city_name'];?>
			            <?php echo $output['address']['dis_name'];?>
		        		<?php echo $output['address']['address'];?>
		        	</span>
		        </div>
		        <?php if($output['order']['is_express']==1){?>
		        <div class="saleUri">	        	        	
		        	<span class="label">发货方式</span>
	            	<span class="valueleft"><?php echo $output['order']['expresscode'];?>(单号：<?php echo $output['order']['express'];?>)</span>            	
		        </div>
		        <?php }?>
		    </div>
		    <?php }else{?>
		    <div class="orderInfoMain">
		        <div class="saleUri">	        	        	
		        	<span class="label">发货方式：</span>
	            	<span class="value">当面交易</span>            	
		        </div>
		    </div>		    
		    <?php }?>
	    <?php }?>
	    
	    <?php if($output['order']['is_tuihuo']==1){?>
	    <div class="orderInfoMain">
	        <div class="title">争议信息</div>
	        <?php if(!empty($output['refund'])){?>
	        <?php foreach($output['refund'] as $val){?>
	        <div class="saleUri">
	        	<span class="label"><?php if($val['type']==1){ echo '卖家';}else{ echo '买家';}?>：</span>
	        	<span class="value"><?php echo $val['refund_reason'];?></span>
	        	<span class="valueleft"><?php echo date("Y-m-d",$val['refund_add_time']);?></span>
	        </div>
	        <?php }?>
	        <?php }?>
	    </div>
	    <?php }?>
	    
	    <?php if(!empty($output['order']['tuihuo_address'])){?>
	    <div class="orderInfoMain">
        	<div class="title">退货信息</div>
        	<div class="saleUri">
	        	<span class="label">收货人：</span>
	        	<span class="value"><?php echo $output['tuihuo_address']['name'];?></span>
	        	<span class="valueleft"><?php echo $output['tuihuo_address']['tele'];?></span>
	        </div>
	        <div class="saleUri">
	        	<span class="value">
	        		<?php echo $output['tuihuo_address']['prov_name'];?>
            		<?php echo $output['tuihuo_address']['city_name'];?>
           			<?php echo $output['tuihuo_address']['dis_name'];?>
	        		<?php echo $output['tuihuo_address']['address'];?>
	        	</span>	
	        </div>
	        <?php if(!empty($output['order']['tuihuo_expresscode'])){?>
        	<div class="saleUri">	        	        	
	        	<span class="label">发货方式</span>
            	<span class="value"><?php echo $output['order']['tuihuo_expresscode'];?></span>
            	<span class="valueleft">(单号：<?php echo $output['order']['tuihuo_express'];?>)</span>            	
	        </div>
	        <?php }?>
	    </div>    
	    <?php }?>   
    </div>
<script type="text/javascript">
$(function(){

	$('.confirmtuikuan').click(function(){
		var order_id = $(this).attr('order_id');		
		location.href = 'index.php?act=payment&op=confirmtuikuan&order_id='+order_id;
	});
	
	$('.mysendout').click(function(){
		var order_id = $(this).attr('order_id');		
		location.href = 'index.php?act=payment&op=sendout&order_id='+order_id;
	});

	$('.refuse').click(function(){	
		var order_id = '<?php echo $output['order']['id']?>';		
		location.href = 'index.php?act=payment&op=refuse&order_id='+order_id;
		
	});

	$('.accept').click(function(){
		var auction_id = '<?php echo $_GET['auction_id'];?>';
		location.href = 'index.php?act=payment&op=accepttuikuan&auction_id='+auction_id;
	});

	$('.currentexchange').click(function(){
		var order_id = $(this).attr('order_id');
		if(confirm('确认当面交易？')){
			$.ajax({
				type:'get',
				url:'index.php?act=order&op=currentexchange',
				data:{order_id:order_id},
				dataType:'json',
				success:function(data){
					if(data.state=='1'){
						location.reload();
					}
					return false;
				}
			});
		}
	});
});
</script>
<?php include template('home/nav');?>
</body>
</html>